#region [file: BancoDAL.cs, author: Lucas Bittencourt]
// File:    BancoDAL.cs
// Author:  Lucas Bittencourt
// Created: segunda-feira, 7 de novembro de 2011 20:48:48
// Purpose: Defines dao implementation class for class Banco
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using NHibernate.Criterion;
using DA_OOMModel;
using DA_OOMModelIDAL;

namespace DA_OOMNHibernateDAL
{
   /// <summary>
   /// Class that implements methods of IBancoDAL interface
   /// </summary>
   public class BancoDAL : NHibernateDALBase,  IBancoDAL 
   {
      #region CRUD methods
      /// <summary>
      /// Get all instances of Banco
      /// </summary>     
      public List<Banco> GetBancoList()
      {
         return ConvertToGenericList(base.LoadAll(typeof(Banco)));
      }
      
      /// <summary>
      /// Get the instances of Banco from index firstResult to index maxResult
      /// </summary>
      public List<Banco> GetBancoList(int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.LoadAll(typeof(Banco), firstResult, maxResult));
      }

      /// <summary>
      /// Load the instance of Banco according its primary key instance.
      /// </summary>
      public Banco Load(BancoPK bancoPK)
      {
         IList cs = new ArrayList();
         string[] paramNames = new string[] { "BncIdBanco" };
         object[] values = new object[] { bancoPK.BncIdBanco };
         for (int i = 0; i < paramNames.Length; i++)
             cs.Add(Expression.Eq(paramNames[i], values[i]));

         IList list = base.FindByCriterions(typeof(Banco), cs);
         return (((list != null) && (list.Count > 0)) ? (Banco)list[0] : null);
      }

      /// <summary>
      /// Query the instances of Banco according its example instance.
      /// </summary>
      public List<Banco> QueryByExample(Banco banco)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(Banco), banco));
      }

      /// <summary>
      /// Query the instances of Banco according its example instance from index firstResult to index maxResult
      /// </summary>
      public List<Banco> QueryByExample(Banco banco, int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(Banco), banco, firstResult, maxResult));
      }
      
      /// <summary>
      /// Insert the instances of Banco
      /// </summary>
      public void Insert(Banco bancoObject)
      {
         base.Save(bancoObject);
      }
      
      /// <summary>
      /// Update the instances of Banco
      /// </summary>
      public void Update(Banco bancoObject)
      {
         base.Update(bancoObject);
      }
      
      /// <summary>
      /// Delete the instances of Banco
      /// </summary>
      public void Delete(Banco bancoObject)
      {
         base.Delete(bancoObject);
      }
      #endregion
      
   
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuBanco
      /// </summary>
      public List<Banco> FindByBncNuBanco(string bncNuBanco) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuBanco", bncNuBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs));
      }
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuBanco, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Banco> FindByBncNuBanco(string bncNuBanco, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuBanco", bncNuBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuDigitoBanco
      /// </summary>
      public List<Banco> FindByBncNuDigitoBanco(string bncNuDigitoBanco) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuDigitoBanco", bncNuDigitoBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs));
      }
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuDigitoBanco, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Banco> FindByBncNuDigitoBanco(string bncNuDigitoBanco, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuDigitoBanco", bncNuDigitoBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNmBanco
      /// </summary>
      public List<Banco> FindByBncNmBanco(string bncNmBanco) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNmBanco", bncNmBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs));
      }
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNmBanco, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Banco> FindByBncNmBanco(string bncNmBanco, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNmBanco", bncNmBanco));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuCnpj
      /// </summary>
      public List<Banco> FindByBncNuCnpj(string bncNuCnpj) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuCnpj", bncNuCnpj));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs));
      }
      
      /// <summary>
      /// Find the instances of Banco according to its attribute bncNuCnpj, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Banco> FindByBncNuCnpj(string bncNuCnpj, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("BncNuCnpj", bncNuCnpj));
         return ConvertToGenericList(base.FindByCriterions(typeof(Banco), cs, firstResult, maxResult));
      }

      /// <summary>
      /// Convert the IList to the generic List instance.
      /// </summary>
      private List<Banco> ConvertToGenericList(IList bancos)
      {
         List<Banco> bancoList = new List<Banco>();
         foreach (Banco banco in bancos)
         {
             bancoList.Add(banco);
         }
         return bancoList;
      }      
   }
}